package com.happyfamily.springboot.crowdsourcingplatform.dao.pan;

import com.happyfamily.springboot.crowdsourcingplatform.model.Need;
import com.happyfamily.springboot.crowdsourcingplatform.model.Work;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @Author Administrator
 * @create 2020/02/23 01:26
 */
@Mapper
public interface PurchaseDao
{


	/**
	 * 查询作品表数据总的条数
	 * @return
	 */
	@Select("select count(*) from work where consumeraccount is null and wstatus ='已审核'")
	Long countAllWorks();


	/**
	 * 获取作品表数据
	 * @param startPosition
	 * @param limit
	 * @return
	 */
	@Select("select * from work where consumeraccount is null and wstatus ='已审核' order by wstarttime desc  limit #{startPosition},#{limit}")
	List<Work> getAllWorksByPage(Integer startPosition, Integer limit);


	/**
	 * 根据作品id拿数据
	 * @param wid
	 * @return
	 */
	@Select("select * from work where wid=#{wid}")
	Work getWorkById(Integer wid);


	/**
	 * 修改作品表改作品为已下单
	 * @param wid
	 * @param account
	 * @return
	 */
	@Update("update work set consumeraccount = #{account} where wid = #{wid}")
	int updateWorkByWid( @Param("wid")String wid, @Param("account") String account);


	/**
	 * 查询订单id
	 * @param wid
	 * @return
	 */
	@Select("select oid from orders where workid=#{wid}")
	Integer getOrdesById(String wid);
}
